import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hx/router/app_pages.dart';
import 'package:flutter_hx/services/app_theme_services.dart';
import 'package:flutter_hx/services/user_service.dart';
import 'package:get/get.dart';

import 'base/utils/preference_utils.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // //状态栏透明
  var systemUiOverlayStyle =
      const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  // //强制竖屏
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
  PreferenceUtils.instance.initSharedPreferences();
  Function originalOnError = FlutterError.onError!;
  FlutterError.onError = (errorDetails) async {
    originalOnError(errorDetails);
  };
  if (kReleaseMode) {
    debugPrint = (message, {wrapWidth}) {};
  }
  runZonedGuarded(() {
    runApp(
      GetMaterialApp(
        debugShowCheckedModeBanner: false,
        title: "Application",
        initialBinding: BindingsBuilder(
          () {
            Get.put(AppThemeServices());
            Get.put(UserService());
          },
        ),
        getPages: AppPages.routes,
        initialRoute: AppPages.initial,
      ),
    );
  }, (error, stackTrace) {});
}
